package com.polaris.live.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.polaris.live.R
import com.polaris.live.common.adapter.BaseAdapter
import com.polaris.live.databinding.AdapterHowPlayBinding
import com.polaris.live.resp.bean.HowPlayBean
import com.polaris.live.utils.image.ImageUtils

/**
 * HowPlayAdapter 玩法说明adapter
 * @author Created by 天晴 on 2024/1/19 11:30
 * @since 1.0.0
 **/
class HowPlayAdapter : BaseAdapter<HowPlayBean, HowPlayAdapter.HowPlayHolder>(0) {


    init {
        addChildClickViewIds(R.id.contect)
    }

    override fun onCreateDefViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): HowPlayHolder {
        return HowPlayHolder(
            AdapterHowPlayBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        )
    }

    override fun convert(holder: HowPlayHolder, item: HowPlayBean) {
        if (item.isChecked) {
            holder.binding.huan.visibility = View.VISIBLE
        } else {
            holder.binding.huan.visibility = View.GONE
        }
        Glide.with(context)
            .load(ImageUtils.imgPath(item.data.iconRound))
            .transform(CircleCrop())
            .into(holder.binding.image)
    }


    inner class HowPlayHolder(val binding: AdapterHowPlayBinding) :
        BaseViewHolder(binding.root)
}